<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>通知公告修改</title>
	<script th:src="@{/layui/layui.js}" type="text/javascript"></script>
	<link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>

<div style="margin: 20px">
	<form class="layui-form layui-form-pane">
		<input type="hidden" id="id" name="id" th:value="${ns.id}">

		<div class="layui-form-item">
			<label class="layui-form-label">公告标题</label>
			<div class="layui-input-block">
				<input class="layui-input" th:value="${ns.title}" name="title" placeholder="输入公告标题" autocomplete="off"/>
			</div>
		</div>
		<!---->
		<div class="layui-form-item">
			<label class="layui-form-label">公告内容</label>
			<div class="layui-input-block">
				<textarea class="layui-textarea" th:text="${ns.content}" name="content" placeholder="输入内容" autocomplete="off"></textarea>
			</div>
		</div>



		<div class="layui-form-item">
			<label class="layui-form-label">更新时间</label>
			<div class="layui-input-inline">
				<input type="text" id="updateTime" name="updateTime" th:value="${ns.updateTime}" lay-verify="datetime" class="layui-input" />
			</div>
		</div>

		<!---->
		<div class="layui-form-item" style="display: none;">
			<div class="layui-input-block">
				<a class="layui-btn" id="submitBtn" lay-submit="" lay-filter="submitBtn">提交</a>
			</div>
		</div>
	</form>
</div>

<!---->
<script>
	var $;
	layui.use(['table','laydate','layedit','form','jquery','layer','upload','element'],function() {
		var table = layui.table,
				layer = layui.layer,
				form = layui.form,
				upload = layui.upload,
				layedit = layui.layedit,
				element = layui.element,
				laydate = layui.laydate;
				$ = layui.jquery;

		laydate.render({
			elem: '#updateTime' //指定元素
		});

		// layedit.build('demo'); //建立编辑器

		form.on('submit(submitBtn)',function (data) {
			var formData = data.field;
			console.log(formData);
			$.ajax({
				type:'post',
				url:'/notice/nc/update',
				data:formData,
				dataType:'json',
				success:function (result) {
					layer.msg(result.msg);
					if (result.is){
						let index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);  //编辑成功后关闭父页面窗口
						parent.layui.table.reload('noticeTable');//根据表格id刷新父页面表格
					}
				}
			})
		})

	});

	function btnSubmit() {
		$('#submitBtn').click();
	}
</script>

</body>
</html>